home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Essentials / MacApp Documentation / MacApp.TECH$ Archives / 1990 / Oct 90 / MacApp.Tech$ 10⁄26⁄90 / 2251-Bug in DemoText MacA-Oct90 < prev    next >
Encoding:
Text File  |  1991-03-06  |  2.0 KB  |  76 lines  |  [TEXT/GEOL]

  1. Item    8905623                         25-Oct-90        18:40PDT
  2.  
  3. From:   NEIL.RHODES                     Palomar SW, Neil Rhodes,PRT
  4.  
  5. To:     MACAPP.TECH$                    MacApp Technical
  6.         MACDTS                          Macintosh Developer Tech Supt
  7.  
  8. Sub:    Bug in DemoText MacApp sa
  9.  
  10. Attn: Macapp Technichal mailing list
  11. Attn: Macintosh Tech Support
  12. SentBy: Neil Rhodes
  13. Date   10/25/90
  14. Subject    Bug in DemoText MacApp samp
  15. From   Neil Rhodes
  16. To Macapp Technichal mailing list
  17. CC Macintosh Tech Support
  18.  
  19.                        Subject:                               Time:4:20 AM
  20.   OFFICE MEMO          Bug in DemoText MacApp sample          Date:10/25/90
  21. In UTEDocument.inc1.p, the initilization method for TTEDocument is:
  22.  
  23.  procedure TTEDocument.ITEDocument (itsFileType, itsCreator: OSType;
  24. usesDataFork, usesRsrcFork: BOOLEAN; keepsDataOpen, keepsRsrcOpen: BOOLEAN);
  25.  
  26.  begin
  27.   fDocText := nil;
  28.   IDocument(itsFileType, itsCreator, usesDataFork, usesRsrcFork,
  29. keepsDataOpen, keepsRsrcOpen);
  30.  
  31.   fTEView := nil;
  32.   fStyles := nil;
  33.   fElements := nil;
  34.   fDocText := NewPermHandle(0);
  35.   FailNIL(fDocText);
  36.  end;
  37.  
  38. Unfortunately, this has a bug.  Initilization methods are supposed to Free the
  39. object being initialized on a failure.  In this initialization, if the
  40. NewPermHandle fails, then, the TTEDocument will not be freed (and therefore,
  41. no one will free it).
  42.  
  43. The fix:
  44. Add a failure handler to free self.
  45.  
  46. procedure TTEDocument.ITEDocument (itsFileType, itsCreator: OSType;
  47. usesDataFork, usesRsrcFork: BOOLEAN; keepsDataOpen, keepsRsrcOpen: BOOLEAN);
  48.  
  49.  var
  50.   fi: FailInfo;
  51.  
  52.  procedure HandleITEDocumentFailure (err: OSErr; message: longint);
  53.  begin
  54.   self.Free;
  55.  end;
  56.  
  57. begin
  58.  fDocText := nil;
  59.  IDocument(itsFileType, itsCreator, usesDataFork, usesRsrcFork, keepsDataOpen,
  60. keepsRsrcOpen);
  61.  
  62.  fTEView := nil;
  63.  fStyles := nil;
  64.  fElements := nil;
  65.  fDocText := NewPermHandle(0);
  66.  CatchFailure(fi, HandleITEDocumentFailure);
  67.  FailNIL(fDocText);
  68.  Success(fi);
  69. end;
  70.  
  71. Neil Rhodes
  72. Applelink Neil.Rhodes
  73. (619) 967-7285
  74.  
  75.  
  76.